<?php
namespace app\common\controller;
use think\Loader;
use think\Controller;
use think\Session;
class Frontend extends Controller
{
    protected $account;
    protected $path;
    protected $noLogin = ['login/index'];
    protected function _initialize()
    {
        $modulename = $this->request->module();
        $controllername = Loader::parseName($this->request->controller());
        $actionname = strtolower($this->request->action());
        $this->path = str_replace('.', '/', $controllername) . '/' . $actionname;
        //dump($this->path);die();
        $this->account = Session::get('ACCOUNT','svip');
        if(in_array($this->path, $this->noLogin)){
            
        }else{
            if(!$this->account){
                $url = $this->request->url();
                $this->redirect('login/index', [], 302, ['referer' => $url]);
                exit();
            }
        }
        $this->assign('account', $this->account);
    }
}